//package cn.nfwx.tv.fragment;
//
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v4.app.Fragment;
//import android.support.v4.app.FragmentTransaction;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//
//import com.flyco.tablayout.SegmentTabLayout;
//import com.flyco.tablayout.listener.OnTabSelectListener;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import cn.nfwx.tv.R;
//import cn.nfwx.tv.base.BaseFragment;
//import cn.nfwx.tv.fragment.subscription.HotColumnFragment;
//import cn.nfwx.tv.fragment.subscription.MineSubscriptionFragment;
//
///**
// * 我的订阅
// * Created by zb.liu on 2017/10/30.
// */
//public class SubscriptionFragment extends Fragment {
//
//    private SegmentTabLayout sub_segment_tab;
//    private List<BaseFragment> fragmentList;
//    private Fragment tempFragment;
//    private HotColumnFragment hotColumnFragment;
//    private MineSubscriptionFragment mineSubscriptionFragment;
//    private String[] titles = {"我的订阅", "热门节目"};
//    private View view;
//
//    public SubscriptionFragment newInstance() {
//        SubscriptionFragment fragment = new SubscriptionFragment();
//        return fragment;
//    }
//
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        view = View.inflate(getActivity(), R.layout.fragment_subscription, null);
//        init();
//
//        return view;
//    }
//
//
//    public void init() {
//        sub_segment_tab = view.findViewById(R.id.sub_segment_tab);
//        sub_segment_tab.setTabData(titles);
//        initFragment();
//
//        sub_segment_tab.setOnTabSelectListener(new OnTabSelectListener() {
//            @Override
//            public void onTabSelect(int position) {
//                switchFragment(tempFragment, fragmentList.get(position));
//            }
//
//            @Override
//            public void onTabReselect(int position) {
//
//            }
//        });
//    }
//
//
//    public void initFragment() {
//        hotColumnFragment = new HotColumnFragment();
//        mineSubscriptionFragment = new MineSubscriptionFragment();
//        fragmentList = new ArrayList<BaseFragment>();
//        fragmentList.add(mineSubscriptionFragment);
//        fragmentList.add(hotColumnFragment);
//
//        switchFragment(tempFragment, fragmentList.get(0));
//    }
//
//    public void switchFragment(Fragment fromFragment, BaseFragment nextFragment) {
//
//        if (tempFragment != nextFragment) {
//            tempFragment = nextFragment;
//            if (nextFragment != null) {
//                FragmentTransaction transaction = this.getChildFragmentManager().beginTransaction();
//                //判断nextFragment是否添加
//                if (!nextFragment.isAdded()) {
//                    //隐藏当前Fragment
//                    if (fromFragment != null) {
//                        transaction.hide(fromFragment);
//                    }
//                    transaction.replace(R.id.sub_container, nextFragment, "tagFragment").commit();
//                } else {
//
//                    //隐藏当前Fragment
//                    if (fromFragment != null) {
//                        Log.d("初始化", "fromFragment不为空");
//                        transaction.hide(fromFragment);
//                    }
//
//                    transaction.show(nextFragment).commit();
//                }
//            }
//        }
//    }
//}
